<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>

<script src="http://localhost/mStoreC2CServer/jquery-latest.min.js" type="text/javascript"></script>

<script>
	$(document).ready(function(){
		$('#btnInsert').click(function(){
			$.ajax({
				url: $('#urlBase').text() + "/index.php/api/userservice/insert",
				data:"username=username5",
				type:"put",
				success: function(result){
					alert(result);
				}
			});
		});

		$('#btnUpdate').click(function(){
			$.ajax({
				url: $('#urlBase').text() + "/index.php/api/userservice/insert",
				data:"Id=11&username=username5",
				type:"post",
				success: function(result){
					alert(result);
				}
			});
		});

		$('#btnGetsAll').click(function(){
			$.ajax({
				url: $('#urlBase').text() + '/index.php/api/userservice/getsAll',
				data:"format=json",
				type:"get",
				success: function(result){
					var str = '';
					for(var i in result){
						for(var j in result[i])
							str += result[i][j] + " | ";
						str += "\r\n";
					}
					alert(str);
				}
			});
		});
		
		$('#btnGetsPage').click(function(){
			$.ajax({
				url: $('#urlBase').text() + "/index.php/api/userservice/getsPage",
				data: "offset=1&length=2&format=json",
				type: "get",
				success: function(result){
					var str = '';
					for(var i in result){
						for(var j in result[i])
							str += result[i][j] + " | ";
						str += "\r\n";
					}
					alert(str);
				}
			});
		});
		
		$('#btnInsertBase').click(function(){
			var datastring = {
					name: 'user',
					data: {
						username: 'username',
						password: 'password',
						createdby: 'username1'
					}
			}
			$.ajax({
				url: $('#urlBase').text() + "/index.php/api/baseservice/insert",
				data: datastring,
				type: "put",
				success: function(result){
					alert(result);
				}
			});
		});

		$('#btnUpdateBase').click(function(){
			var datastring = {
					name: 'user',
					id: 11,
					data: {
						username: 'username1',
						password: 'password1',
						modifiedby: 'username1'
					}
			}
			$.ajax({
				url: $('#urlBase').text() + "/index.php/api/baseservice/update",
				data: datastring,
				type: "post",
				success: function(result){
					alert(result);
				}
			});
		});

		$('#btnGetsBase').click(function(){
			var datastring = {
					select: '*', 
					from: 'user', 
					orderby: 'updatedDate desc',
					limit: '2,1',//length,offset
					format: 'json'// required
					};
			$.ajax({
				url: $('#urlBase').text() + "/index.php/api/baseservice/gets",
				data: datastring,
				type: "get",
				success: function(result){
					var str = '';
					for(var i in result){
						for(var j in result[i])
							str += result[i][j] + " | ";
						str += "\r\n";
					}
					alert(str);
				}
			});
		});
		
		$('#btnGetIdBase').click(function(){
			var datastring = {
					name: 'user', 
					id: '11',
					format: 'json'// required
					};
			$.ajax({
				url: $('#urlBase').text() + "/index.php/api/baseservice/get",
				data: datastring,
				type: "get",
				success: function(result){
					var str = '';
					for(var i in result){
						str += result[i] + " | ";
					}
					alert(str);
				}
			});
		});
		
		$('#btnGetsMulti').click(function(){
			var datastring = {
					select: 'products.productCode, products.productName, suppliers.rowid, suppliers.fullname', 
					from: 'products',
					join: 'suppliers',
					joinon: 'products.rowidSupplier = suppliers.rowid',
					orderby: 'products.updatedDate desc',
					//limit: '2,1',//length,offset
					format: 'json'// required
					};
			$.ajax({
				url: $('#urlBase').text() + "/index.php/api/baseservice/gets",
				data: datastring,
				type: "get",
				success: function(result){
					var str = '';
					for(var i in result){
						for(var j in result[i])
							str += result[i][j] + " | ";
						str += "\r\n";
					}
					alert(str);
				}
			});
		});
});
</script>
</head>
<body>
Hello everyone!
<div>
	<label id="urlBase">http://localhost/mStoreC2CServer</label>
	<br/>
	<input type="button" id="btnInsert" value="Insert Data"/>
	<br/>
	<input type="button" id="btnUpdate" value="Update Data"/>
	<br/>
	<input type="button" id="btnGetsAll" value="GetsAll"/>
	<br/>
	<input type="button" id="btnGetsPage" value="GetsPage"/>
	<br/>
	<input type="button" id="btnInsertBase" value="Insert Data Base Service"/>
	<br/>
	<input type="button" id="btnUpdateBase" value="Update Data Base Service"/>
	<br/>
	<input type="button" id="btnGetsBase" value="Gets By Base Service"/>
	<br/>
	<input type="button" id="btnGetIdBase" value="GetId By Base Service"/>
	<br/>
	<input type="button" id="btnGetsMulti" value="Gets multiple table"/>
</div>

<div id="content"></div>
</body>
</html>